package com.zls;

import com.zls.mapper.TDeviceMapper;
import com.zls.pojo.TDevice;
import com.zls.service.TDeviceService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@SpringBootTest(classes = OnlinefarmApplication.class)
@RunWith(SpringRunner.class)
public class Demo {
    @Autowired
    private PasswordEncoder passwordEncoder;

    @Test
    public void demo(){
        PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        String encode = passwordEncoder.encode("123456");
        System.out.println(encode);
        boolean matches = passwordEncoder.matches( "123456",encode);
        boolean matches1 = passwordEncoder.matches( "123456","$2a$10$Cr0gzvuSR771rHBy/6zX3eIbR1Yan07zok9ROV0ADNiwdd/iqLvT6");
        System.out.println(matches);
        System.out.println(matches1);
    }

    @Autowired
    private TDeviceMapper tDeviceMapper;
    @Test
    public void demo01(){
        List<TDevice> tDevices = tDeviceMapper.selectList(null);
        tDevices.stream().forEach(o->System.out.println(o));
    }
    @Autowired
    private TDeviceService tDeviceService;
    @Test
    public void demo02(){
        tDeviceService.findAll();
    }
}
